<script type="text/javascript" src="__PUBLIC__/kindeditor/kindeditor-min.js" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/huploadify/huploadify.css">
<script type="text/javascript" src="__PUBLIC__/huploadify/huploadify.js" charset="utf-8"></script>
<volist name="form_items" id="form">
    <div class="form-group">
        <if condition='$form.type neq group'>
            <label class="item-label">{$form.title}<span class="check-tips">（{$form.tip}）</span></label>
        </if>
        <div class="controls">
            <switch name="form.type">
                <case value="hidden">
                    <input type="hidden" name="{$form.name}" value="{$form.value}">
                </case>
                <!-- 数字 -->
                <case value="num">
                    <input type="text" class="form-control num" name="{$form.name}" value="{$form.value}">
                </case>
                <!-- 字符串 -->
                <case value="text">
                    <input type="text" class="form-control text" name="{$form.name}" value="{$form.value}">
                </case>
                <!-- 文本 -->
                <case value="textarea">
                    <textarea class="form-control textarea" name="{$form.name}">{$form.value}</textarea>
                </case>
                <!-- 数组 -->
                <case value="array">
                    <textarea class="form-control textarea" name="{$form.name}">{$form.value}</textarea>
                </case>
                <!-- 密码 -->
                <case value="password">
                    <input type="password" class="form-control password" name="{$form.name}" value="{$form.value}">
                </case>
                <!-- 单选按钮 -->
                <case value="radio">
                    <foreach name="form.options" item="option" key="option_key">
                        <label class="radio-inline" for="{$form.name}{$option_key}">
                            <input type="radio" id="{$form.name}{$option_key}" name="{$form.name}" value="{$option_key}" <eq name="form.value" value="$option_key"> checked</eq> class="checkbox"> {$option}
                        </label>
                    </foreach>
                </case>
                <!-- 复选框 -->
                <case value="checkbox">
                    <foreach name="form.options" item="option" key="option_key">
                        <label class="checkbox-inline">
                            <input type="checkbox" name="{$form.name}" value="{$option_key}" <in name="option_key" value="$form.value"> checked</in>>{$option}
                        </label>
                    </foreach>
                </case>
                <!-- 下拉框 -->
                <case value="select">
                    <select name="{$form.name}" class="form-control">
                        <foreach name="form.options" item="option" key="option_key">
                            <option value="{$option_key}" <eq name="form.value" value="$option_key"> selected</eq>>{$option}</option>
                        </foreach>
                    </select>
                </case>
                <!-- 日期 -->
                <case value="date">
                    <textarea class="form-control" name="{$form.name}">{$form.value}</textarea>
                </case>
                <!-- 时间 -->
                <case value="date">
                    <textarea class="form-control" name="{$form.name}">{$form.value}</textarea>
                </case>
                <!-- 图片 -->
                <case value="picture">
                    <div id="upload_{$key}"></div>
                    <div id="preview_{$key}">
                        <input type="hidden" name="{$form.name}" value="{$form.value}">
                        <img style="margin-top:8px;max-height:60px;" src="{$form.value|get_cover}">
                    </div>
                    <script type="text/javascript">
                        $('#upload_{$key}').Huploadify({
                            uploader:'{:U("Index/upload")}',
                            fileTypeExts:'*.gif;*.jpg;*.jpeg;*.png;*.bmp',
                            fileSizeLimit:{:C('UPLOAD_IMAGE_SIZE')}*1024,
                            buttonText:'上 传 图 片',
                            onUploadComplete:function(file, data){
                                var data = $.parseJSON(data);
                                $('#preview_{$key} img').attr('src', data.url);
                                $('#preview_{$key} input').attr('value', data.id);
                            }
                        });
                    </script>
                </case>
                <!-- 编辑器 -->
                <case value="kindeditor">
                    <textarea id="kindeditor_{$key}" name="{$form.name}" class="form-control">{$form.value}</textarea>
                    <script type="text/javascript">
                        var editor_{$tab_key};
                        KindEditor.ready(function(K) {
                            kindeditor_{$key} = K.create('#kindeditor_{$key}', {
                                allowFileManager : false,
                                width: '100%',
                                height: '200px',
                                cssPath : [
                                    '__PUBLIC__/zui/css/zui.min.css',
                                    '__PUBLIC__/kindeditor/plugins/code/prettify.css'
                                ],
                                resizeType: 1,
                                pasteType : 2,
                                urlType : 'absolute',
                                items : [{:C('EDITOR_STYLE_SIMPLE')}],
                                fileManagerJson : '{:U("Index/fileManager")}',
                                uploadJson : '{:U("Index/upload")}',
                                remoteImgSaveUrl: '{:U("Index/downremoteimg")}',
                                extraFileUploadParams: {
                                    session_id : '{:session_id()}'
                                },
                                afterBlur: function(){this.sync();},
                                autoSaveMode:true,
                                autoSaveInterval:100,
                                afterCreate: function() {
                                    this.loadPlugin('autosave');
                                }
                            });
                        });
                    </script>
                </case>
                <!-- 标签 -->
                <case value="tag">
                    <textarea class="form-control" name="{$form.name}">{$form.value}</textarea>
                </case>
                <case value="group">
                    <ul class="nav-pills nav">
                        <volist name="form.options" id="li">
                            <li data-tab="tab{$i}" <eq name="i" value="1">class="active"</eq>><a href="#tab{$i}" data-toggle="tab">{$li.title}</a></li>
                        </volist>
                    </ul>
                    <div class="tab-content">
                        <volist name="form.options" id="tab">
                            <div id="tab{$i}" class='tab-pane <eq name="i" value="1">active</eq> tab{$i}'>
                                <div class="controls">
                                    <volist name="tab.options" id="tab_form" key="tab_key">
                                        <div class="form-group">
                                            <label class="item-label">{$tab_form.title}<span class="check-tips">（{$tab_form.tip}）</span></label>
                                            <div class="controls">
                                                <switch name="tab_form.type">
                                                    <case value="hidden">
                                                        <input type="hidden" name="{$tab_form.name}" value="{$tab_form.value}">
                                                    </case>
                                                    <!-- 数字 -->
                                                    <case value="num">
                                                        <input type="text" class="form-control num" name="{$tab_form.name}" value="{$tab_form.value}">
                                                    </case>
                                                    <!-- 字符串 -->
                                                    <case value="text">
                                                        <input type="text" class="form-control text" name="{$tab_form.name}" value="{$tab_form.value}">
                                                    </case>
                                                    <!-- 文本 -->
                                                    <case value="textarea">
                                                        <textarea class="form-control textarea" name="{$tab_form.name}">{$tab_form.value}</textarea>
                                                    </case>
                                                    <!-- 数组 -->
                                                    <case value="array">
                                                        <textarea class="form-control textarea" name="{$form.name}">{$form.value}</textarea>
                                                    </case>
                                                    <!-- 密码 -->
                                                    <case value="password">
                                                        <input type="password" class="form-control password" name="{$tab_form.name}" value="{$tab_form.value}">
                                                    </case>
                                                    <!-- 单选按钮 -->
                                                    <case value="radio">
                                                        <foreach name="tab_form.options" item="option" key="option_key">
                                                            <label class="radio-inline" for="{$form.name}{$option_key}">
                                                                <input type="radio" id="{$form.name}{$option_key}" name="{$tab_form.name}" value="{$option}" <eq name="tab_form.value" value="$option_key"> checked</eq> class="checkbox"> {$option}
                                                            </label>
                                                        </foreach>
                                                    </case>
                                                    <!-- 复选框 -->
                                                    <case value="checkbox">
                                                        <foreach name="tab_form.options" item="option" key="option_key">
                                                            <label class="checkbox-inline">
                                                                <input type="checkbox" name="{$tab_form.name}" value="{$option_key}" <in name="option_key" value="$tab_form.value"> checked</in>>{$opt}
                                                            </label>
                                                        </foreach>
                                                    </case>
                                                    <!-- 下拉框 -->
                                                    <case value="select">
                                                        <select name="{$tab_form.name}" class="form-control">
                                                            <foreach name="tab_form.options" item="option" key="option_key">
                                                                <option value="{$option_key}" <eq name="tab_form.value" value="$option_key"> selected</eq>>{$option}</option>
                                                            </foreach>
                                                        </select>
                                                    </case>
                                                    <!-- 日期 -->
                                                    <case value="date">
                                                        <textarea class="form-control" name="{$tab_form.name}">{$tab_form.value}</textarea>
                                                    </case>
                                                    <!-- 时间 -->
                                                    <case value="date">
                                                        <textarea class="form-control" name="{$tab_form.name}">{$tab_form.value}</textarea>
                                                    </case>
                                                    <!-- 图片 -->
                                                    <case value="picture">
                                                        <div id="upload_{$tab_key}"></div>
                                                        <div id="preview_{$tab_key}">
                                                            <input type="hidden" name="{$form.name}" value="{$tab_form.value}">
                                                            <img style="margin-top:8px;max-height:60px;" src="{$tab_form.value|get_cover}">
                                                        </div>
                                                        <link rel="stylesheet" type="text/css" href="__PUBLIC__/huploadify/huploadify.css">
                                                        <script type="text/javascript" src="__PUBLIC__/huploadify/huploadify.js" charset="utf-8"></script>
                                                        <script type="text/javascript">
                                                            $('#upload_{$tab_key}').Huploadify({
                                                                uploader:'{:U("Index/upload")}',
                                                                fileTypeExts:'*.gif;*.jpg;*.jpeg;*.png;*.bmp',
                                                                fileSizeLimit:{:C('UPLOAD_IMAGE_SIZE')}*1024,
                                                                buttonText:'上 传 图 片',
                                                                onUploadComplete:function(file, data){
                                                                    var data = $.parseJSON(data);
                                                                    $('#preview_{$tab_key} img').attr('src', data.url);
                                                                    $('#preview_{$tab_key} input').attr('value', data.id);
                                                                }
                                                            });
                                                        </script>
                                                    </case>
                                                    <!-- 编辑器 -->
                                                    <case value="kindeditor">
                                                        <textarea id="kindeditor_{$tab_key}" name="{$tab_form.name}" class="form-control">{$tab_form.value}</textarea>
                                                        <script type="text/javascript">
                                                            var kindeditor_{$tab_key};
                                                            KindEditor.ready(function(K) {
                                                                kindeditor_{$tab_key} = K.create('#kindeditor_{$tab_key}', {
                                                                    allowFileManager : false,
                                                                    width: '100%',
                                                                    height: '200px',
                                                                    cssPath : [
                                                                        '__PUBLIC__/zui/css/zui.min.css',
                                                                        '__PUBLIC__/kindeditor/plugins/code/prettify.css'
                                                                    ],
                                                                    resizeType: 1,
                                                                    pasteType : 2,
                                                                    urlType : 'absolute',
                                                                    items : [{:C('EDITOR_STYLE_SIMPLE')}],
                                                                    fileManagerJson : '{:U("Index/fileManager")}',
                                                                    uploadJson : '{:U("Index/upload")}',
                                                                    remoteImgSaveUrl: '{:U("Index/downremoteimg")}',
                                                                    extraFileUploadParams: {
                                                                        session_id : '{:session_id()}'
                                                                    },
                                                                    afterBlur: function(){this.sync();},
                                                                    autoSaveMode:true,
                                                                    autoSaveInterval:100,
                                                                    afterCreate: function() {
                                                                        this.loadPlugin('autosave');
                                                                    }
                                                                });
                                                            });
                                                        </script>
                                                    </case>
                                                    <!-- 标签 -->
                                                    <case value="tag">
                                                        <textarea class="form-control" name="{$tab_form.name}">{$tab_form.value}</textarea>
                                                    </case>
                                                </switch>
                                            </div>
                                        </div>
                                    </volist>
                                </div>
                            </div>
                        </volist>
                    </div>
                </case>
            </switch>
        </div>
    </div>
</volist>
